package cc.idoone.spring_boot_hello.mybatis.h2.service;

import cc.idoone.spring_boot_hello.mybatis.h2.dao.BaseMapper;
import cc.idoone.spring_boot_hello.mybatis.h2.dao.MyBatisH2UserDao;
import cc.idoone.spring_boot_hello.mybatis.h2.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author hemj
 * @since 2017/10/19
 */
@Service
@Transactional(transactionManager = "h2MyBatisTransactionManager")
public class UserDaoServiceImpl extends AbstractLongService<User> implements UserDaoService {

	private MyBatisH2UserDao myBatisH2UserDao;

	@Autowired
	public UserDaoServiceImpl(MyBatisH2UserDao myBatisH2UserDao) {
		this.myBatisH2UserDao = myBatisH2UserDao;
	}

	@Override
	protected BaseMapper<User, Long> getMapper() {
		return myBatisH2UserDao;
	}

	@Override
	public List<User> listAll() {
		return myBatisH2UserDao.listAll();
	}
}
